<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>websocket在线测试</title>
    <link rel="stylesheet" href="./websocket_files/index.css"/>
    <link rel="stylesheet" href="./websocket_files/bootstrap.min.css"/>
</head>
<body>
<div>
    <div class="zone_conn">
        <input type="text" class="form-control" style="float:left;" id="inp_url"
               value="" placeholder="wss://域名/路由地址"/>
        <button type="button" id="btn_conn" class="btn btn-primary"
                style="float:left;margin-left:10px;margin-right:10px;" onclick="fun_initWebSocket();">连接
        </button>
        <button type="button" id="btn_close" class="btn btn-danger" style="float:left;" onclick="fun_close();"
                disabled="disabled">断开
        </button>
    </div>
    <div class="zone_send">
        <textarea id="inp_send" class="form-control" style="height:100px;" placeholder="发送的内容"></textarea>
        <br/>
        <button type="button" id="btn_send" class="btn btn-info" onclick="fun_sendto();">发送（ctrl+回车）</button>
    </div>
</div>
<div style="position:absolute;top:0px;left:470px;">
    <div id="div_msgzone" class="panel panel-default">
        <div class="panel-heading">
            消息窗口
        </div>
        <div id="div_msg" class="panel-body" style="width: 1420px; height: 767px;"></div>
    </div>
</div>
<!-- Modal -->
<script type="text/javascript" src="./websocket_files/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="./websocket_files/bootstrap.min.js"></script>
<script type="text/javascript" src="./websocket_files/indextp.js"></script>
</body>
</html>
<script>
    window.onload = function () {
        document.getElementById("inp_url").value = 'https:' == document.location.protocol ? "wss://" + window.location.host + "/ws?token=" + Math.ceil(Math.random()*10) : "ws://" + window.location.host + "?token=" + Math.ceil(Math.random()*10);
        fun_initWebSocket();
    }
</script>